package com.xiaolai.iodemo;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;

import com.xiaolai.iodemo.graphics.MyTips;

public class FirstPage extends Activity {
    public static TextView textPort = null;
    public static TextView textIp = null;
    public static TextView textAlias =null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_firstpage);
        init();
    }

    protected void init() {
        textPort = (TextView) findViewById(R.id.editText_port);
        textIp = (TextView) findViewById(R.id.editText_Ip);
        textAlias =(TextView)findViewById(R.id.editText_alias);
    }

    public void onClick_Join(View v)
    {
        Intent intent=new Intent().setClass(this, MainActivity.class);
        intent.putExtra("port", textPort.getText().toString());
        intent.putExtra("alias", textAlias.getText().toString());
            if (true/*!SimpleStrChecker.ipv4(textIp.getText().toString())*/){
        MyTips.showToastText(this.getApplicationContext(),"IP地址错误");
        return;
    }
        intent.putExtra("ip", textIp.getText().toString());
        startActivity(intent);
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_mysocket, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}
